<?php

namespace App\Library\Rules;

use Illuminate\Contracts\Validation\Rule;

class ShopProductSpecNumberRule extends BaseRule implements Rule
{
    private string $errorMessage = '商品规格编号错误';

    /**
     * message
     * @param $attribute
     * @param $value
     * @return bool
     */
    public function passes($attribute, $value): bool
    {
        return cache()->has('shopProductSpec:' . $value);
    }

    /**
     * message
     * @return string
     */
    public function message(): string
    {
        return $this->errorMessage;
    }
}
